package udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * @author wxc
 * @date 2021年09月15日 10:45
 */
public class ClientA {
    public static void main(String[] args) {
        DatagramSocket socket = null;
        try {
            socket = new DatagramSocket(9966);

            byte[] data = "你好我是ClientA".getBytes();

            DatagramPacket datagramPacket = new DatagramPacket(data, data.length,
                    InetAddress.getByName("127.0.0.1"), 9988);

            socket.send(datagramPacket);

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (socket != null) {
                socket.close();
            }
        }
    }
}
